package com.wu.llpsw.event;

import com.wu.llpsw.entity.villager.ModVillagers;
import com.wu.llpsw.item.ModItems;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.trading.MerchantOffer;
import net.minecraftforge.event.village.VillagerTradesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;
//import com.wu.llpsw.item.*;
@Mod.EventBusSubscriber(modid = "wu")
public class villagerJiaoYi {

    // 村民交易事件
    @SubscribeEvent
    public static void addCustomTrades(VillagerTradesEvent event){

        // 若果是修士职业
        if(event.getType() == ModVillagers.XIUSHI.get()) {
            // 获得交易列表，int2ObjectMap对象，不同等级提供的交易项目
            Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades();
            // 创一个ItemStack，lieHuoZhang物品，1个
            ItemStack nianTuQiu = new ItemStack(Items.CLAY_BALL,1);
            ItemStack cuiHuoZhang = new ItemStack(ModItems.cuiHuoZhang.get(),1);
            ItemStack guiJiaShu = new ItemStack(ModItems.guiJiaShu.get(),1);
            ItemStack hanDiJue = new ItemStack(ModItems.hanDiJue.get(),1);
            ItemStack jiuYouJian = new ItemStack(ModItems.jiuYouJian.get(),1);
            ItemStack lieHuoZhang = new ItemStack(ModItems.lieHuoZhang.get(),1);
            ItemStack tengJiaShu = new ItemStack(ModItems.tengJiaShu.get(),1);
            ItemStack xiZhang = new ItemStack(ModItems.xiZhang.get(),1);
            ItemStack xueJiShu = new ItemStack(ModItems.xueJiShu.get(),1);
            ItemStack xuanLeiDuanTi = new ItemStack(ModItems.xuanLeiDuanTi.get(),1);
            ItemStack yeHuoDuanTi = new ItemStack(ModItems.yeHuoDuanTi.get(),1);
            ItemStack zhongZiYuanMi = new ItemStack(ModItems.zhongZiYuanMi.get(),1);
            ItemStack zhongZiYuanLingGuo = new ItemStack(ModItems.zhongZiYuanLingGuo.get(),1);
            ItemStack zhongZiDiaoLingSan = new ItemStack(ModItems.zhongZiDiaoLingSan.get(),1);
            ItemStack zhongZiJiuXianCao = new ItemStack(ModItems.zhongZiJiuXianCao.get(),1);
            ItemStack zhongZiYuanGangGuo = new ItemStack(ModItems.zhongZiYuanGangGuo.get(),1);
            ItemStack xueDing = new ItemStack(ModItems.xueDing.get(),1);
            ItemStack diDing = new ItemStack(ModItems.diDing.get(),1);
            ItemStack anDing = new ItemStack(ModItems.anDing.get(),1);
            ItemStack yaoJian = new ItemStack(ModItems.yaoJian.get(),1);
            ItemStack jingTieFu = new ItemStack(ModItems.jingTieFu.get(),1);
            ItemStack yuanZunJue=new ItemStack(ModItems.yuanZunJue.get(),1);
            ItemStack ziYangJue=new ItemStack(ModItems.ziYangJue.get(),1);
            ItemStack buSiJing=new ItemStack(ModItems.buSiJing.get(),1);
            ItemStack sanShengJing=new ItemStack(ModItems.sanShengJing.get(),1);
            ItemStack wuXiangJue=new ItemStack(ModItems.wuXiangJue.get(),1);
            int villagerLevel =1 ;
            //添加一个新的交易。获得的物品的是 stack，提供的物品是绿宝石，5个，10表示最大的交易次数，8表示交易返回经验值，0.02f表示价格乘区
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,5),
                    nianTuQiu,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,10),
                    cuiHuoZhang,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,30),
                    guiJiaShu,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,30),
                    hanDiJue,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,50),
                    jiuYouJian,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,10),
                    lieHuoZhang,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,30),
                    tengJiaShu,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,10),
                    xiZhang,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,50),
                    xueJiShu,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,50),
                    xuanLeiDuanTi,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,40),
                    yeHuoDuanTi,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,50),
                    zhongZiYuanMi,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,60),
                    zhongZiYuanLingGuo,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,60),
                    zhongZiDiaoLingSan,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,80),
                    zhongZiJiuXianCao,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,80),
                    zhongZiYuanGangGuo,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,100),
                    xueDing,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,100),
                    diDing,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,100),
                    anDing,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,40),
                    yaoJian,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,40),
                    jingTieFu,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,5),
                    yuanZunJue,10,8,0.02F
            ));


            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,10),
                    ziYangJue,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,100),
                    buSiJing,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,90),
                    sanShengJing,10,8,0.02F
            ));
            trades.get(villagerLevel).add((trader,rand) -> new MerchantOffer(
                    new ItemStack(Items.EMERALD,50),
                    wuXiangJue,10,8,0.02F
            ));
        }
    }
}
